package org.sucri.floxs.ext;

import org.sucri.floxs.Tools;

import java.util.Collection;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

/**
 * Created by IntelliJ IDEA.
 * User: Wen Yu
 * Date: Jul 15, 2007
 * Time: 11:05:34 PM
 * To change this template use File | Settings | File Templates.
 */
public class Ext_Util
{
  /*public static <T extends JsonConfig> String toJS(Collection<T> rs)
  {
    JSONArray array = new JSONArray();
    if (Tools.good(rs))
    {
      //for (T r : rs) array.put(r.toJSONObject());
    }
    return array.toString();
  } */
  public static JSONObject putAsString(JSONObject jo, String key, Object val)
  {
    if (val != null && key != null)
    {
      if (jo == null) jo = new JSONObject();
      jo.put(key, val.toString());
    }
    return jo;
  }
  public static JSONObject putFrom(JSONObject jo, String key, JSONObject src)
  {
    if (src != null && key != null && src.has(key))
    {
      if (jo == null) jo = new JSONObject();
      jo.put(key, src.get(key));
    }
    return jo;
  }
}
